package com.capgemini.diabeo.service;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

import com.capgemini.diabeo.manager.DishManager;
import com.capgemini.diabeo.manager.DishManager_;
import com.capgemini.diabeo.manager.MealStatus;
import com.capgemini.diabeo.model.Category;
import com.capgemini.diabeo.model.Dish;
import com.capgemini.diabeo.model.DishDao;
import com.googlecode.androidannotations.annotations.Bean;
import com.googlecode.androidannotations.annotations.EBean;

@EBean
public class InitDBService extends AbstractDatabaseService {

	@Bean
	CategoryService categoryService;
	
	@Bean
	DishManager dishManager;

	@Bean
	DishService dishService;

	public void initDatabase() {
		MealStatus[] mealTab = new MealStatus[] {
				MealStatus.BREAKFAST, MealStatus.LUNCH_TIME,
				MealStatus.DINNER };

		DishDao dishDao = dbHelper.getDishDao();
		for (MealStatus meal : mealTab) {
			insertImages(meal);
		}
		
		
	/*	for (MealStatus meal : mealTab) {
			createCategoriesAndDish(meal);
		}*/
	}

	private void createCategoriesAndDish(MealStatus mealTime) {
		List<Category> categories = categoryService.createCategory(6, mealTime);
		for (Category category : categories) {
			dishService.createDishes(10, category);
		}
	}
	
	private void insertImages(MealStatus mealTime)
	{
		List<Category> categories = categoryService.createCategory(8, mealTime);
		//List<Dish> lalala = dishManager.retrieveDishByMenuStatus();
		for (Category category : categories) {
			dishService.insertImages(category);
		}
	}
}
